<template>
  <div class="app-container">
    <!-- 按钮组 -->
    <el-row>
      <el-col :span="12">
        <el-button type="primary" plain @click="openDrawer">新增</el-button>
        <el-button type="success" plain>高级搜索</el-button>
      </el-col>
      <el-col :span="12">
        <div>
          <el-input placeholder="请输入内容">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </div>
      </el-col>
    </el-row>
    <!-- 表格 -->
    <el-table
      :data="list"
      style="width: 100%; margin-top: 20px"
      max-height="400"
      ref="multipleTable"
    >
      <el-table-column fixed type="selection" width="50"> </el-table-column>
      <el-table-column type="index" label="#" width="120"> </el-table-column>
      <el-table-column prop="title" label="题目" width="300"> </el-table-column>
      <el-table-column prop="type" label="分类" width="300"> </el-table-column>
      <el-table-column prop="author" label="作者" width="50"> </el-table-column>
      <el-table-column prop="date" sortable label="发布时间" width="200">
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="120">
        <template slot-scope="scope">
          <el-button type="text" size="small"> 编辑 </el-button>
          <el-button type="text" size="small"> 详情 </el-button>
          <el-button @click="deleteRow(scope.row.id)" type="text" size="small">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[3, 5, 8, 10]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
    <!-- 抽屉 -->
    <el-drawer size="70%" :visible.sync="drawer" direction="rtl"> </el-drawer>
  </div>
</template>

<script>
import { mapActions, mapState, mapMutations } from "vuex";
export default {
  data() {
    return {
      drawer: false,
    };
  },
  mounted() {
    this.getlist();
  },
  methods: {
    ...mapActions("msbd", ["getlist"]),
    ...mapMutations("msbd", ["SET_PAGESIZE", "SET_CURRENTPAGE"]),
    deleteRow(id) {},
    openDrawer() {
      this.drawer = true;
    },
    handleSizeChange(val) {
      this.SET_PAGESIZE(val);
      this.getlist();
    },
    handleCurrentChange(val) {
      this.SET_CURRENTPAGE(val);
      this.getlist();
    },
  },
  computed: {
    ...mapState("msbd", ["list", "total", "currentPage", "pageSize"]),
    ...mapState("classify", ["classifyList"]),
  },
};
</script>

<style scoped>
</style>